﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace Hx.Infrastructure.Helpers
{
    public class SecurityHelper
    {
        /// <summary>
        ///     MD5加密
        /// </summary>
        /// <param name="encyptStr">加密明文</param>
        public static string Md5Encrypt(string encyptStr)
        {
            var m5 = new MD5CryptoServiceProvider();
            var inputBye = Encoding.ASCII.GetBytes(encyptStr);
            var outputBye = m5.ComputeHash(inputBye);
            var retStr = Convert.ToBase64String(outputBye);
            return retStr;
        }

        /// <summary>
        ///     SHA1加密
        /// </summary>
        /// <param name="encyptStr">加密明文</param>
        public static string Sha1Encrypt(string encyptStr)
        {
            var sha1 = new SHA1CryptoServiceProvider();
            var inputBye = Encoding.ASCII.GetBytes(encyptStr);
            var outputBye = sha1.ComputeHash(inputBye);
            var retStr = Convert.ToBase64String(outputBye);
            return retStr;
        }

    }
}